package com.study.thread.顺序执行;

import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class 加锁_1 {
    static int i;
    public static void main(String[] args) {
       /* final Thread MyThread1=new Thread(new Runnable(){
            @Override
            public void run() {
                str=str+"_"+"A";
            }
        });

        final Thread MyThread2=new Thread(new Runnable(){
            @Override
            public void run() {
                str=str+"_"+"B";
            }
        });
        final Thread MyThread3=new Thread(new Runnable(){
            @Override
            public void run() {
                str=str+"_"+"C";
                System.out.println(str);
            }
        });*/
        new Thread(new Mythread()).start();
        new Thread(new Mythread()).start();
        new Thread(new Mythread()).start();
    }

    static class Mythread implements Runnable{

        @Override
        public void run() {
            synchronized (this.getClass()){
                i+=1;
                System.out.println(i);
            }
        }
    }
}